var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, i) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var i in t)
              Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
          })(t, i);
      };
      return function (t, i) {
        function a() {
          this.constructor = t;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        e(t, i),
          (t.prototype =
            null === i
              ? Object.create(i)
              : ((a.prototype = i.prototype), new a()));
      };
    })(),
  AXMaterialDialog = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.jiCunFun = {
          caller: t,
          code: 1446,
          method: function (e) {
            t.close(), ToastView.toastView(e.msg);
          },
        }),
        (t.jiCunZhuangBeiFun = {
          caller: t,
          code: 1427,
          method: function (e) {
            t.close(), ToastView.toastView(e.msg);
          },
        }),
        (t.quChuFun = {
          caller: t,
          code: 1435,
          method: function (e) {
            t.close(), ToastView.toastView(e.msg);
          },
        }),
        (t.quChuZhuangBeiFun = {
          caller: t,
          code: 1433,
          method: function (e) {
            t.close(), ToastView.toastView(e.msg);
          },
        }),
        t.btn_material_sure.on(
          Laya.Event.CLICK,
          t,
          t.onDidClickMaterialEventFn
        ),
        t.btn_material_cancle.on(Laya.Event.CLICK, t, t.close),
        WebSocketService.addListener(t.jiCunFun),
        WebSocketService.addListener(t.quChuFun),
        WebSocketService.addListener(t.jiCunZhuangBeiFun),
        WebSocketService.addListener(t.quChuZhuangBeiFun),
        WebSocketService.addListener({
          caller: t,
          code: 1071,
          method: t.onLoadUseShouLiJianDataFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 5310,
          method: t.onLoadUseShouLiJianDataFn,
        }),
        t.btn_materia_dele.on(Laya.Event.CLICK, t, t.numberChangeBtnClick),
        t.btn_materia_plus.on(Laya.Event.CLICK, t, t.numberChangeBtnClick),
        t.material_slider.on(Laya.Event.CHANGE, t, t.sliderValueChangeFn),
        t
      );
    }
    return (
      __extends(t, e),
      (t.showMateralView = function (e, i, a, n) {
        null == this.materialDialog &&
          ((this.materialDialog = new t()), (this.materialDialog.zOrder = 1e3)),
          this.materialDialog.popup(!0),
          this.materialDialog.initData(),
          (this.materialDialog.material_type = i),
          (this.materialDialog.goods_type = a),
          (this.materialDialog.jsonDict = e),
          n
            ? ((this.materialDialog.isCommon = n),
              (this.materialDialog.btn_material_sure.label = "确定"),
              (this.materialDialog.label_materialtitle.text = e.name))
            : "背包" == i
            ? ((this.materialDialog.label_materialtitle.text = "寄存"),
              (this.materialDialog.btn_material_sure.label = "寄存"))
            : "仓库" == i
            ? ((this.materialDialog.btn_material_sure.label = "提取"),
              (this.materialDialog.label_materialtitle.text = "提取"))
            : "手里剑" == i &&
              ((this.materialDialog.btn_material_sure.label = "使用"),
              (this.materialDialog.label_materialtitle.text = "手里剑")),
          (this.materialDialog.label_materialNumber.text =
            this.materialDialog.material_slider.value + " 个"),
          (this.materialDialog.number_value = 1),
          (this.materialDialog.number_step = 1),
          (this.materialDialog.maxValueStr = e.num),
          (this.materialDialog.label_materialname.text = e.name),
          (this.materialDialog.material_slider.max =
            3 == a ? 1 : parseInt(e.num)),
          (this.materialDialog.material_slider.min = 0),
          (this.materialDialog.material_slider.value = 1),
          (this.materialDialog.number_value =
            this.materialDialog.material_slider.value);
      }),
      (t.prototype.initData = function () {
        this.isCommon = !1;
      }),
      (t.prototype.numberChangeBtnClick = function (e) {
        if ("item1" == e.target.name) {
          if (
            ((this.number_value = this.number_value + this.number_step),
            this.number_value > parseInt(this.maxValueStr))
          )
            return (
              (this.number_value = parseInt(this.maxValueStr)),
              void this.updateMaterialData()
            );
        } else if (
          (e.target.name = "item0") &&
          ((this.number_value = this.number_value - this.number_step),
          this.number_value < 1)
        )
          return (this.number_value = 1), void this.updateMaterialData();
        this.updateMaterialData();
      }),
      (t.prototype.updateMaterialData = function () {
        (this.material_slider.value = this.number_value),
          this.currentSliderValueChangeFn(this.number_value);
      }),
      (t.prototype.onDidClickMaterialEventFn = function (e) {
        this.isCommon
          ? WebSocketService.send({
              c: 5310,
              d: { goodsId: this.jsonDict.id, count: this.number_value },
            })
          : "提取" == e.target.label
          ? 3 == this.goods_type
            ? WebSocketService.send({
                c: 1433,
                d: { pageNum: 0, armingId: this.jsonDict.id },
              })
            : 1 == this.goods_type
            ? WebSocketService.send({
                c: 1435,
                d: {
                  gid: this.jsonDict.id,
                  type: this.goods_type,
                  count: this.number_value,
                  bind: 0,
                  pageNum: 0,
                },
              })
            : 5 == this.goods_type
            ? WebSocketService.send({
                c: 1435,
                d: {
                  gid: this.jsonDict.id,
                  type: this.goods_type,
                  count: this.number_value,
                  bind: 0,
                  pageNum: 0,
                },
              })
            : 4 == this.goods_type &&
              WebSocketService.send({
                c: 1435,
                d: {
                  gid: this.jsonDict.id,
                  type: this.goods_type,
                  count: this.number_value,
                  bind: 0,
                  pageNum: 0,
                },
              })
          : "寄存" == e.target.label
          ? 3 == this.goods_type
            ? WebSocketService.send({
                c: 1427,
                d: { pageNum: 0, armingId: this.jsonDict.id },
              })
            : 1 == this.goods_type
            ? WebSocketService.send({
                c: 1446,
                d: {
                  gid: this.jsonDict.id,
                  type: this.goods_type,
                  bind: 0,
                  count: this.number_value,
                  pageNum: 0,
                },
              })
            : 5 == this.goods_type
            ? WebSocketService.send({
                c: 1446,
                d: {
                  gid: this.jsonDict.id,
                  type: this.goods_type,
                  bind: 0,
                  count: this.number_value,
                  pageNum: 0,
                },
              })
            : 4 == this.goods_type &&
              WebSocketService.send({
                c: 1446,
                d: {
                  gid: this.jsonDict.id,
                  type: this.goods_type,
                  bind: 0,
                  count: this.number_value,
                  pageNum: 0,
                },
              })
          : "使用" == e.target.label &&
            WebSocketService.send({
              c: 1071,
              d: { gid: this.jsonDict.id, count: this.number_value },
            });
      }),
      (t.prototype.onClickMaterialSetMaxValueFn = function () {
        (this.material_slider.value = parseInt(this.maxValueStr)),
          (this.number_value = this.material_slider.value),
          this.currentSliderValueChangeFn(this.number_value);
      }),
      (t.prototype.sliderValueChangeFn = function () {
        (this.number_value = this.material_slider.value),
          this.currentSliderValueChangeFn(this.number_value);
      }),
      (t.prototype.currentSliderValueChangeFn = function (e) {
        this.label_materialNumber.text = e + " 个";
      }),
      (t.prototype.onLoadUseShouLiJianDataFn = function (e) {
        0 == e.code &&
          (5310 == e.act_id
            ? WebSocketService.send({ c: 1425, d: { pageNum: 0 } })
            : 1425 == e.act_id &&
              WebSocketService.send({ c: 1425, d: { pageNum: 0 } })),
          this.close(),
          ToastView.toastView(e.msg);
      }),
      t
    );
  })(ui.AXMaterialDialogUI);
